package com.cindata

import com.cindata.dictionary.*

class ContactImport
{

    ContactImportBatch batch

    String externalId
    String fullName
    String sex
    ContactIdentityType identityType
    String idNumber
    String cellphone
    String address
    String bankAccountNo
    String householdAddress
    String workUnitName
    String position

    String reason

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User createBy
    User modifyBy

    ExecStatusDict evaluateStatue

    ContactImport()
    {
    }

    ContactImport(ContactImportBatch batch, String externalId, String fullName, String sex, ContactIdentityType identityType, String idNumber, String cellphone,
        String address, String bankAccountNo, String householdAddress, String workUnitName, String position, Date createdDate, User createBy)
    {
        this.batch = batch
        this.externalId = externalId
        this.fullName = fullName
        this.sex = sex
        this.identityType = identityType
        this.idNumber = idNumber
        this.cellphone = cellphone
        this.address = address
        this.bankAccountNo = bankAccountNo
        this.householdAddress = householdAddress
        this.workUnitName = workUnitName
        this.position = position
        this.createdDate = createdDate
        this.createBy = createBy
    }

    static constraints = {
        batch nullable: true, blank: true
        externalId nullable: true, blank: true
        fullName nullable: true, blank: true
        sex nullable: true, blank: true
        identityType nullable: true, blank: true
        idNumber nullable: true, blank: true
        cellphone nullable: true, blank: true
        address nullable: true, blank: true
        bankAccountNo nullable: true, blank: true
        householdAddress nullable: true, blank: true
        workUnitName nullable: true, blank: true
        position nullable: true, blank: true


        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true

        evaluateStatue nullable: true, blank: true
        reason nullable: true, blank: true

    }

    def afterUpdate()
    {
        this.updateMatchNum()
    }

    // 验证成功，进入押品表,关联关系不明确，暂时不需要进入押品表
    def validSuccess()
    {
        //        def contact = new Contact()
        //        contact.fullName = this.fullName
        //        contact.sex = this.sex
        //        contact.identityType = this.identityType
        //        contact.idNumber = this.idNumber
        //        contact.cellphone = this.cellphone
        //        contact.address = this.address
        //        //contact.bankAccountNo = this.bankAccountNo
        //        contact.householdAddress = this.householdAddress
        //        contact.workUnitName = this.workUnitName
        //        contact.position = this.position
        //        contact.save()
    }

    /*
    * 验证失败
     */

    def validFailure()
    {
    }

    // 更新匹配记录数量
    def updateMatchNum()
    {
        this.batch.updateCount()
    }

}
